<?php
declare(strict_types=1);
namespace cms\wechat\admin\mvc_controller;

use cms\wechat\service\PlatformService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\AutoController;
use Psr\Http\Message\ResponseInterface;

/**
 * 微信开放平台
 * Class PlatformController
 * @package cms\wechat\admin\mvc_controller
 * @AutoController(prefix="mvc/wechat/admin_platform")
 */
class PlatformController extends CommonController
{
    /**
     * @Inject()
     * @var PlatformService
     */
    protected PlatformService $platformService;

    /**
     * 列表
     * @return ResponseInterface
     */
    public function retrieve(): ResponseInterface
    {
        return $this->template();
    }

    /**
     * 创建
     * @return ResponseInterface
     */
    public function create(): ResponseInterface
    {
        return $this->template([], 'form');
    }

    /**
     * 更新
     * @return ResponseInterface
     */
    public function update(): ResponseInterface
    {
        $id = (int) $this->request->input('id', 0);
        $data = $this->platformService->getDataById($id, true);
        return $this->template([
            'data' => $data
        ], 'form');
    }
}